package com.example.demo.solon.controller;

import com.example.demo.solon.config.AppConfig;
import com.example.demo.solon.config.DemoDbConfig;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.Properties;
import org.noear.solon.annotation.Controller;
import org.noear.solon.annotation.Inject;
import org.noear.solon.annotation.Mapping;
import org.noear.solon.cloud.annotation.CloudConfig;

/**
 * @author airhead
 */
@Api("配置管理")
@Controller
@Mapping("/config")
public class DemoController {
  /** 获取dataId的配置，获取不到值 */
  @Inject private DemoDbConfig demoDbConfig;

  @Inject private AppConfig appConfig;

  @CloudConfig(value = "demo-db", autoRefreshed = true)
  private Properties properties;

  @CloudConfig(value = "demo-db", autoRefreshed = true)
  private DemoDbConfig demoDbConfig2;

  @ApiOperation("db")
  @Mapping("db")
  public DemoDbConfig db() {
    return demoDbConfig;
  }

  @ApiOperation("db2")
  @Mapping("db2")
  public Properties db2() {
    return properties;
  }

  @ApiOperation("app")
  @Mapping("app")
  public AppConfig app() {
    return appConfig;
  }
}
